package org.monkey.socket.plugin.handler;

import io.netty.channel.ChannelHandlerContext;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.monkey.socket.plugin.entity.SocketMsg;
import org.monkey.socket.plugin.service.IMsgSendFailedHandler;

@Data
@Slf4j
public class DefaultMsgSendFailedHandler implements IMsgSendFailedHandler {

  @Override
  public void handlerFail(ChannelHandlerContext ctx, SocketMsg socketMsg, Exception e) {
    if (ctx != null) {
      log.error("msg send failed:{},channelId:{},e=", socketMsg, ctx.channel().id(), e);
    } else {
      log.error("msg send failed:{},channelId:null,e=", socketMsg, e);
    }
  }
}
